{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Running verify PaddlePaddle program ... \n",
      "PaddlePaddle works well on 1 CPU.\n",
      "PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.\n"
     ]
    }
   ],
   "source": [
    "import paddle\n",
    "from paddle.nn import Linear\n",
    "import paddle.nn.functional as F\n",
    "import numpy as np\n",
    "import os\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "paddle.utils.run_check()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJIAAACcCAYAAACUcfL+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAACltJREFUeJztnW2MVNUZx39/VnYF5LWLDayENSwSaROBLLWGBvEN0BQJH5ogBiqxKWlAbApBKEkhDUktNm2CkLTWEmqpNBZFpLEhYOADsSXsBoJLcRUs4Jb3WMBiU4GefpjLes8t7M7OnLkzs/P8ksmc/z137n1m959zn3vPnefKOYdh5EuPYgdgdA/MSEYQzEhGEMxIRhDMSEYQzEhGECraSJKOSXq42HF0ByraSEY4zEhGEMxIgKSVkv4oaaOkTyW9J+kuScsknZX0saTJsfXnSjocrfuRpHmJ7S2RdErSSUnfkeQkNUR9NZJ+JumEpDOSfimpV9rfOTRmpC+YBvwOGAjsB7aT+fvUAT8GfhVb9yzwTaAfMBf4haRxAJKmAj8AHgYagPsT+/kpcBcwJuqvA35UkG+UJs65in0Bx8j8w1cCO2LLpwH/Aqoi3RdwwICb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GUlSTzIm+r1z7vq5blYlkq08cmXQaY6kTM2V3wCHnXM/j3WVVYnkM2fOePrQoUOeXrBggafff//9nPeVfDTpkiVLPD19+nRPl8N1os7I5oLkBGA28J6kA9GyH5Ix0GtRueQTwLcKE6JRDmRz1rYHuFklKCuRbAB2ZdsIRLeZa/vkk088nXxM1oEDBzydLOXXVSZMmNDeTv7Wf8qUKZ7u1atXXvsqB2xEMoJgRjKCYEYyglBWOdLevXvb26tXr/b6kvdFt7W15bWv3r17ezr5+Pb4/Fjy8eyViI1IRhDMSEYQyurQtmXLlhu2syH5E59p06Z5uqqqytOLFy/2dLK6v+FjI5IRBDOSEQQzkhEEK2tjdIiVtTFSxYxkBMGMZATBjGQEwYxkBMGMZATBjGQEwYxkBMGMZATBjGQEwYxkBCHVuTZJ54DjQC1wPrUdd41Sja1YcQ13znVatCFVI7XvVGrKZiKwGJRqbKUa13Xs0GYEwYxkBKFYRnqpSPvNhlKNrVTjAoqUIxndDzu0GUFI1UiSpkpqlXREUlHLKUtaL+mspJbYspKoHV6Otc1TM5KkKmAd8CgwGngiqtddLDYAUxPLSqV2ePnVNnfOpfIC7gO2x/QyYFla+79JTPVAS0y3AkOi9hCgtZjxxeLaCjxSqvE551I9tNUBH8d0W7SslCi52uHlUts8TSPdqA6lnTJ2QK61zYtBmkZqA4bF9B3AyRT3nw1Z1Q5Pg3xqmxeDNI20Dxgp6U5J1cBMMrW6S4nrtcOhiLXDs6htDqVW2zzlpPEx4APgKLC8yAnsJjIP67lCZrR8GvgSmbOhD6P3QUWK7RtkDvsHgQPR67FSie9GL7uybQTBrmwbQTAjGUEwIxlBMCMZQTAjGUEwIxlBMCMZQTAjGUH4H60RPj4/ZNCIAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 144x144 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "图据: (28, 28)\n",
      "biaoqian: (1,) [5]\n",
      "/n shujudi[5]\n"
     ]
    }
   ],
   "source": [
    "train_dataset=paddle.vision.datasets.MNIST(mode='train')\n",
    "train_data0=np.array(train_dataset[0][0])\n",
    "train_label_0=np.array(train_dataset[0][1])\n",
    "import matplotlib.pyplot as plt\n",
    "plt.figure('lmage')\n",
    "plt.figure(figsize=(2,2))\n",
    "plt.imshow(train_data0,cmap=plt.cm.binary)\n",
    "plt.axis('on')\n",
    "plt.title('lmage')\n",
    "plt.show()\n",
    "print('图据:',train_data0.shape)\n",
    "print(\"biaoqian:\",train_label_0.shape,train_label_0)\n",
    "print('/n shujudi{}'.format(train_label_0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "class MNIST(paddle.nn.Layer):\n",
    "    def __init__(self):\n",
    "        super(MNIST,self).__init__()\n",
    "        self.fc1=Linear(in_features=784,out_features=100)\n",
    "        self.fc2=Linear(in_features=100,out_features=100)\n",
    "        self.fc3=Linear(in_features=100,out_features=10)\n",
    "    def forward(self,inputs):\n",
    "        outputs1=self.fc1(inputs)\n",
    "        outputs1=F.relu(outputs1)\n",
    "        outputs2=self.fc2(outputs1)\n",
    "        outputs2=F.relu(outputs2)\n",
    "        outputs_final=self.fc3(outputs2)\n",
    "        outputs_final=F.softmax(outputs_final)\n",
    "        return outputs_final"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "def norm_img(img):\n",
    "    assert len(img.shape)==3\n",
    "    batch_size,img_h,img_w=img.shape[0],img.shape[1],img.shape[2]\n",
    "    img=img/255\n",
    "    img=paddle.reshape(img,[batch_size,img_h*img_w])\n",
    "    return img"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "import paddle\n",
    "paddle.vision.set_image_backend('cv2')\n",
    "model=MNIST()\n",
    "def train(model):\n",
    "    model.train()\n",
    "    train_loader=paddle.io.DataLoader(paddle.vision.datasets.MNIST(mode=\"train\"),\n",
    "                                     batch_size=16,\n",
    "                                     shuffle=True)\n",
    "    op=paddle.optimizer.SGD(learning_rate=1e-2,parameters=model.parameters())\n",
    "    EPOCH_NUM=5\n",
    "    for epoch in range(EPOCH_NUM):\n",
    "        for batch_id,data in enumerate(train_loader()):\n",
    "            images=norm_img(data[0]).astype('float')\n",
    "            labels=data[1].astype('int64')\n",
    "            perdicts=model(images)\n",
    "            loss=F.cross_entropy(predicts,labels)\n",
    "            avg_loss=paddle.mean(loss)\n",
    "            if batch_id % 1000==0:\n",
    "                print('epoch_id:{},batch_id{},loss is:{}'.format(epoch,batch_id,avg_loss.numpy()))\n",
    "        avg_loss.backward()\n",
    "        opt.step()\n",
    "        opt.clear_grad()\n",
    "    train(model)\n",
    "    paddle.save(midel.state_dict(),'./mnist.pdparams')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP0AAAD8CAYAAAC8aaJZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJztnWuQHNWVoL9TVf1Sv9Utdav17AYhCQiwiQahHQwavIywjadnIkYReCd2CS8R7HrBy+7seAw7P9g/E8HsY7zjmB1HMAPrR3gsGC/2YIc8gwYPu2FsgZAFCElIaiShV+vZL7W6Vd1ddfdHVRZFK29mqjKrq1p5vghFqfPezHtuZp68mfece44YY1AUJT4kKi2Aoijziyq9osQMVXpFiRmq9IoSM1TpFSVmqNIrSswom9KLyIMiclBEBkXkqXK1oyjKtSHlsNOLSBI4BDwAnAR2AV8yxuyPvDFFUa6Jco30dwGDxpgjxphpYBswUKa2FEW5BlJlOu5y4ETR3yeBjbbKnZ2dZs2aNWUSRVHiw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DZYBXRWR3PssPQJcxZggg/7u0YtKVH1tf43IvPJH/fHmh6DNuXvteaaUPnAbrOuI3jDF3kHudfVxE7q20QFVCHO6FbwE3AJ8ChoD/kd8+r32vtNIHToN1vWCMOZ3/PQf8iNxr3FnnVTb/e85+hAWPra/X/b1gjDlrjMkYY7LAX/HxK/y89r3SSr8LWCsivSJSS24y45UKy1Q2RKRRRJqd/wO/BbxPrs+P5Ks9AvxdZSScF2x9fQX4V/lZ/LuBMecz4HphzhzF75K79jDP6eBKzVobCcaYWRF5AvgHIAm8YIzZV0mZykwX8CMRgdy5/xtjzN+LyC5ymX8fBY4DWysoY2RYUqI9i3tftwOfJzeJNQl8ed4FjhBL3zeLyKfIvbofA/4NgDFmXtPBqUeeosSMSr/eK4oyz6jSK0rMUKVXlJihSq8oMUOVXlFihiq9osQMVXpFiRmq9IoSM/4/S2yrLTQctiAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原始图像形状: (173, 167)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD8CAYAAAC4nHJkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAErdJREFUeJzt3X9sVWWaB/DvI7SAUJDSgkCrsqg4SBSw/FA2i6swYQCj88coqCMr43T+GJOdOH8sIeoYklUiDqPGdZRZyEAcHTHVxUSCgD+CkxhiURxg2AU0deiWtNWqA1EZgWf/6MGt2PO8l3vuuefA8/0kpu197nvPy22/3ts+57yvqCqIyJ9zsp4AEWWD4SdyiuEncorhJ3KK4SdyiuEncorhJ3KK4SdyiuEncqpvOQ9WXV2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s/0uTPmlcnzVva3/SLSB8A+ALMBtAJ4B8BCVf1LWScSQ0RaADSoauY9YRH5JwBHAKxT1QnRbQ8D6FLV5dH/OIeq6r/lZG4PADiS9c7N0YYyI3vuLA3gJgD/ggyfO2NeNyOD5y2LV/6pAA6o6oeq+ncAfwRwYwbzyD1V3Qag65SbbwSwNvp8Lbp/eMouZm65oKqHVPXd6PPDAE7uLJ3pc2fMKxNZhH80gIM9vm5Fvrb8VgCbRWSHiDRmPZlejIi2TT+5ffrwjOdzquDOzeV0ys7SuXnuitnxutSyCH9v6zrlqeUwQ1UnA/gBgJ9Hb2+pMAXt3FwuvewsnQvF7nhdalmEvxVAfY+v6wC0ZTCPXqlqW/SxA8BLyN/uw+0nN0mNPnZkPJ9v5Gnn5t52lkYOnrs87XidRfjfAXCJiIwRkUoACwC8nME8vkNEBkZ/iIGIDATwfeRv9+GXASyKPl8EYEOGc/mWvOzcHLezNDJ+7vK243UmJ/lErYxHAfQBsEZV/73sk+iFiPwDul/tge6VjZ/Ncm4i8hyAa9F91Vc7gF8B+C8A6wFcAOCvAH6kqmX/w1vM3K5F91vXb3ZuPvk7dpnn9o8A3gKwC8CJ6Oal6P79OrPnzpjXQmTwvPEMPyKneIYfkVMMP5FTDD+RUww/kVMMP5FTDD+RUww/kVMMP5FT/wfKqro5jluD3AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "采样后图像形状: (28, 28)\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from PIL import Image\n",
    "img_path='0.jpg'\n",
    "im=Image.open(img_path)\n",
    "plt.imshow(im)\n",
    "plt.show()\n",
    "im=im.convert('L')\n",
    "print('原始图像形状:',np.array(im).shape)\n",
    "im=im.resize((28,28),Image.ANTIALIAS)\n",
    "plt.imshow(im)\n",
    "plt.show()\n",
    "print(\"采样后图像形状:\",np.array(im).shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\paddle\\nn\\layer\\layers.py:1897: UserWarning: Skip loading for fc1.weight. fc1.weight is not found in the provided dict.\n",
      "  warnings.warn(f\"Skip loading for {key}. \" + str(err))\n",
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\paddle\\nn\\layer\\layers.py:1897: UserWarning: Skip loading for fc1.bias. fc1.bias is not found in the provided dict.\n",
      "  warnings.warn(f\"Skip loading for {key}. \" + str(err))\n",
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\paddle\\nn\\layer\\layers.py:1897: UserWarning: Skip loading for fc2.weight. fc2.weight is not found in the provided dict.\n",
      "  warnings.warn(f\"Skip loading for {key}. \" + str(err))\n",
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\paddle\\nn\\layer\\layers.py:1897: UserWarning: Skip loading for fc2.bias. fc2.bias is not found in the provided dict.\n",
      "  warnings.warn(f\"Skip loading for {key}. \" + str(err))\n",
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\paddle\\nn\\layer\\layers.py:1897: UserWarning: Skip loading for fc3.weight. fc3.weight is not found in the provided dict.\n",
      "  warnings.warn(f\"Skip loading for {key}. \" + str(err))\n",
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\paddle\\nn\\layer\\layers.py:1897: UserWarning: Skip loading for fc3.bias. fc3.bias is not found in the provided dict.\n",
      "  warnings.warn(f\"Skip loading for {key}. \" + str(err))\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "本次预测的数字是: 0\n"
     ]
    }
   ],
   "source": [
    "def load_image(img_path):\n",
    "    im=Image.open(img_path).convert('L')\n",
    "    im=im.resize((28,28),Image.ANTIALIAS)\n",
    "    im=np.array(im).reshape(1,-1).astype(np.float32)\n",
    "    im=1 - im/255\n",
    "    return im\n",
    "model=MNIST()\n",
    "params_file_path='mnist.pdparams'\n",
    "param_dict=paddle.load(params_file_path)\n",
    "model.load_dict(param_dict)\n",
    "model.eval()\n",
    "tensor_img=load_image(img_path)\n",
    "result=model(paddle.to_tensor(tensor_img))\n",
    "print(\"本次预测的数字是:\",np.argsort(result.numpy())[0][-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
